<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>账号信息查询</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
</head>
<body>
<div class="project whitebg">
    <div>
        <input type="hidden" id="projectId" value="${projectId}">
        <table id="tableList" style="height: 400px;" class="layui-hide" lay-filter="tableList"></table>
    </div>
    <script type="text/html" id="toolBar">
        <a class="layui-btn layui-btn-xs  layui-btn-normal" lay-event="resetPassword" style="margin-left: 0px;">重置密码</a>
    </script>
</div>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript">
    var layer;
    var form = layui.form;
    var table = null;
    var tableIns = null;
    //注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
    var element = "";
    layui.use('element', function () {
        element = layui.element;
    });

    layui.use('table', function () {
        table = layui.table;
        element = element;
        //方法级渲染
        tableIns = table.render({
            id: 'tableList',
            elem: '#tableList',
            url: '/zx/projectManager/showProjectListAc?projectId=' + '${projectId}',
            cols: [[
                {
                    title: '序号', width: '5%', templet: function (res) {
                        return res.LAY_INDEX;
                    }
                },
                {field: 'userId', title: 'userId', width: '10%', hide:true,sort: true},
                {field: 'username', title: '用户名', width: '11%', sort: true},
                {field: 'realName', title: '姓名', width: '12%', sort: true},
                {field: 'userType', title: '账号类型', width: '11%', sort: true},
                {field: 'companyName', title: '单位名称', width: '20%', sort: true},
                {field: 'createBy', title: '创建人', width: '10%', sort: true},
                {field: 'createDate', title: '创建时间', width: '15%', sort: true},
                {title: '默认密码', width: '9%', sort: false,templet: '<div>{{ 12345678 }}</div>'},
                {field: '操作', title: '操作', width: '8%', toolbar: "#toolBar"}
            ]],
            height: 'full-110',
            done: function (res, currentCount) {
                //***重点***：table渲染完成后渲染element进度条
                element.render()
            }
        });
        //监听工具条
        table.on('tool(tableList)', function (obj) {
            var data = obj.data;
            var that = $(this);
            if(obj.event === 'resetPassword') {
                parent.layer.confirm('确定重置密码？', function (index) {
                    var userId=data.userId;
                    layerAjax("resetPassword", {id: userId}, "", function (d) {
                        if (d.flag) {
                            parent.layer.close(index);
                            layer.msg("操作成功", {icon: 1});
                            tableIns.reload();
                        } else {
                            layer.msg("操作失败", {icon: 2});
                        }
                    })
                });
            }
        });
    });


</script>

</body>

</html>
